/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import database.models.Tasks;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author Dhawal
 */
public class MyTableModel implements TableModel {

    private String columnNames[] = {"Sr. No", "Priority", "Title", "Due Date", "Status"};
    private Class columnClasses[] = {Integer.class, Integer.class, String.class, Date.class, String.class};
    private ArrayList<Tasks> taskList;

    public MyTableModel(ArrayList<Tasks> taskList) {
        this.taskList = taskList;
    }

    @Override
    public int getRowCount() {
        return taskList.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return columnNames[columnIndex];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return columnClasses[columnIndex];
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Tasks tasks = taskList.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return tasks.getTaskId();
            case 1:
                return tasks.getPriority();

            case 2:
                return tasks.getTitle();
            case 3:
                return tasks.getDueBy();
            case 4:
                return tasks.getStatus();
        }
        return null;

    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    }

    @Override
    public void addTableModelListener(TableModelListener l) {
    }

    @Override
    public void removeTableModelListener(TableModelListener l) {
    }
}
